<?php
class DbApi{
    public $db;
    function __construct(){
        $this->db = new Mysql();
    }
//分页
	function getNumRows($sql){
	    $num = $this->db->sql_fetch_num_rows($sql);   
	    return $num;
	}
	function getPageSql($sql,$Sortid,$type='up'){
	   	$this->page = new Page ( $sql, 10 );
		$sql = $this->page->StartPage($Sortid,$type);
	    return $sql;
	}
	function getPage(){
	    $ret['RecordNum'] = $this->page->RecordNum;
        $ret['TotalPage'] = $this->page->TotalPage;
        $ret['NowPage'] = $this->page->NowPage;
	    $ButtonArray = array(
		'<img src='.BASEPATH.'public/admin/images/first.gif align="absbottom"/>',
		'<img src='.BASEPATH.'public/admin/images/back.gif align="absbottom"/>',
		'<img src='.BASEPATH.'public/admin/images/next.gif align="absbottom"/>',
		'<img src='.BASEPATH.'public/admin/images/last.gif align="absbottom"/>');
		$ret['page'] = $this->page->EndPage($ButtonArray,"select",true);
		return $ret;
	}
	//后台管理员
	function getAdmUser(){
        $sql = "select * from adm_user";
	    $sql = $this->getPageSql($sql,'id');
        $ret['data'] = $this->db->sql_fetch_rows($sql);
        $ret['page'] = $this->getPage();
	    return $ret; 
	}
	//后台账号登录验证
    function checkUser($username,$password){
        $sql = "select password from adm_user where username='$username' limit 1";
        $ret = $this->db->sql_fetch_one_cell($sql);
        return $ret;
    }
}
?>